{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="mb-20" method="get" action="{:url('RewardTask/index')}">
        一级分类：
        <div class="select-box" style="width:120px">
            <select name="first_id" class="select">
                <option value="0">全部</option>
                {volist name="firstClass" id="vo"}
                <option value="{$vo.id}" {if condition="$Request.param.first_id eq $vo.id" }selected{
                /if}>{$vo.title}</option>
                {/volist}
            </select>
        </div>
        任务状态：
        <div class="select-box" style="width:120px">
            <select name="status" class="select">
                <option value="10" {if condition="$Request.param.status eq 10" }selected{/if}>全部</option>
                <option value="2" {if condition="$Request.param.status eq 2 or !$Request.param.status" }selected{/if}>审核中</option>
                <option value="5" {if condition="$Request.param.status eq 5" }selected{/if}>申诉中</option>
                <option value="3" {if condition="$Request.param.status eq 3" }selected{/if}>审核通过</option>
            </select>
        </div>
        审核方式：
        <div class="select-box" style="width:120px">
            <select name="type" class="select">
                <option value="10" {if condition="$Request.param.type eq 10" }selected{/if}>全部</option>
                <option value="1" {if condition="$Request.param.type eq 1" }selected{/if}>免审</option>
                <option value="2" {if condition="$Request.param.type eq 2" }selected{/if}>自审</option>
                <option value="3" {if condition="$Request.param.type eq 3 or !$Request.param.type" }selected{/if}>平台审核</option>
            </select>
        </div>
        任务id：
        <input type="text" class="input-text" style="width:50px" placeholder="任务id" name="task_id" value="{$Request.param.task_id}">
        <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </form>
    <div class="cl pd-5 bg-1 bk-gray">
        <button class="btn btn-secondary" id="authd" onclick="authd(this)" name="">批量审核</button>
        <button class="btn btn-secondary" id="allauthd" onclick="allauthd(this)" name="">全部通过</button>
        <span class="r"> 共有数据 ：<strong>{$count}</strong> 条</span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            <th><input type="checkbox" id="ckAll" onclick="checkAll()"/>全选</th>
            <th>编号</th>
            <th>{:sort_by('任务id','task_id')}</th>
            <th>接单者</th>
            <th>任务标题</th>
            <th>任务单价</th>
            <th>任务状态</th>
            <th>示例图片</th>
            <th>任务图片</th>
            <th>{:sort_by('接取时间','add_time')}</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">
            <td><input type="checkbox" name="ck" value="{$vo.id}"/></td>
            <td> {$vo.id}</td>
            <td> {$vo.task_id}</td>
            <td>{$vo.nickname}</td>
            <td>{$vo.title}</td>
            <td>{$vo.unit_price}</td>
            <td>{if condition="$vo.status eq 2"}
                审核中
                {elseif condition="$vo.status eq 5"/}
                申诉中
                {else/}
                审核通过
                {/if}
            </td>
            <?php $case_img = json_decode(json_decode($vo['case_img'])); ?>
            <td class="enlarge" width="200">
                {volist name="case_img" id="cis"}
                <img src="{$cis}" width="60" height="60" onclick="fdimg('{$cis}')">
                {/volist}
            </td>
            <?php $img = json_decode(json_decode($vo['img'])); ?>
            <td class="enlarge" width="200">
                {volist name="img" id="imgs"}
                <img src="{$imgs}" width="60" height="60" onclick="fdimg('{$imgs}')">
                {/volist}
            </td>
            <td>{$vo.add_time}</td>
            <td class="f-14">
                {tp:access action="edit"}
                {if condition="$vo.status eq 2"}
                <a class="label btn-success radius" style="background-color:#5eb95e" href="javascript:;"
                   onclick="layer_open('审核','{:\\think\\Url::build(\'edit\', [\'id\'=>$vo[\'id\']])}')">审核</a>
                {elseif condition="$vo.status eq 5"/}
                <a class="label btn-danger radius" style="background-color:cadetblue" href="javascript:;"
                   onclick="layer_open('申诉','{:\\think\\Url::build(\'appeal\', [\'id\'=>$vo[\'id\']])}')">申诉</a>
                {/if}
                {/tp:access}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page}</div>
    <div id="fdimg" style="display: none" onclick="sfdimg()">
        <img src="" id="fdimgss">
    </div>
</div>
<style>
    #fdimg{
        background: rgba(0,0,0,0.5);
        position: absolute;
        top:0;
        left:0;
        right: 0;
        bottom: 0;
        display: flex;
        justify-content: center;
        align-self: center;
    }
    #fdimg #fdimgss{
        margin-top: 200px;
        width: 400px;
        height: 600px;
    }
</style>
<script>
    function fdimg(info) {
        $('#fdimgss').attr('src',info)
        $('#fdimg').show()
    }
    function sfdimg() {
        $('#fdimg').hide()
        $('#fdimgss').attr('src','')
    }

    //全选控制所有子框
    function checkAll(ckAll) {
        var cks = document.getElementsByName("ck");
        for (var i = 0; i < cks.length; i++) {
            cks[i].checked = ckAll.checked;
        }
    }
    //全选控制所有子框
    function authd() {
        var ids = [];
        $("input[name='ck']:checked").each(function (i) {
            ids.push($(this).val())

        })
        $.post("{:url('RewardTask/flagqmy')}", {ids: ids},
            function (data) {
                if (data.msg == 1000) {
                    parent.layer.msg('成功', {icon: 6, time: 1000});
                    window.location.reload();
                } else if (data.msg == 1002) {
                    layer.msg('失败!', {icon: 5, time: 1000});
                } else if (data.msg == 1001) {
                    parent.layer.msg('参数错误', {icon: 5, time: 1000});

                }
            });
    }  //全选控制所有子框
    function allauthd() {
        var first_id = $("select[name='first_id']").val();
        var status = $("select[name='status']").val();
        layer.confirm("确定全部通过吗？", {
            btn: ['确定', '取消'],
            title: '提示',
            icon: 3
        }, function () {
            $.post("{:url('RewardTask/allauthd')}", {first_id: first_id, status: status}, function (data) {
                if (data.msg == 1000) {
                    parent.layer.msg('成功', {icon: 6, time: 1000});
                    window.location.reload();
                } else if (data.msg == 1002) {
                    layer.msg('失败!', {icon: 5, time: 1000});
                } else if (data.msg == 1001) {
                    parent.layer.msg('参数错误', {icon: 5, time: 1000});
                }
            }, 'json')
        }, function (index) {
            layer.close(index);
        })
    }

</script>
{/block}